package book;

import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-04-14
 * Time: 17:28
 */
public class Main {
    public static User login(){
        Scanner scanner=new Scanner(System.in);
        while(true){
            System.out.println("请输入用户名");
            String name=scanner.nextLine();
            System.out.println("请选择>:1.管理员用户   2.普通用户");

            int choice=scanner.nextInt();

            if(choice==1){
                return new AdminUser(name);
            }else if(choice==2){
                return new NormalUser(name);
            }
            else{
                System.out.println("输入错误,重新输入");
            }
        }
    }
    public static void main(String[] args) {
        BookList bookList=new BookList();
      User user= login();
     while(true){
       int choice= user.menu();
         user.doOperation(choice,bookList);
     }
    }
}
